home *** CD-ROM | disk | FTP | other *** search
- #ifndef SHAPE_H
- #define SHAPE_H
-
- // -[Keep_Heading]-
-
- // -[Copyright_Mesg]-
- // --------------------------------------------------------------- //
- // (c) Copyright 1993-1994. Step Ahead Software Pty Limited. All rights reserved.
- // Class Name : Shape
- // Designer : Example Writer
- // Filename : SHAPE.h
- // Description :
- // Base class for all shapes. The pure virtual function Show is redefined
- // in derived classes for their individual needs.
- //
- // Future enhancements - double click on an object to change its colour,
- // drag the corners to size the object.
- // --------------------------------------------------------------- //
-
- // ==================================================
- // = LIBRARY
- // Step 3 Graphics Example
- // = FILENAME
- // SHAPE.cpp
- // = RCSID
- // $Id$
- // = AUTHOR
- // Example Writer
- // = COPYRIGHT
- // (c) Copyright 1993-1994. Step Ahead Software Pty Limited. All rights reserved.
- // ==================================================
- #define CC_GEN 1
- #include <OBJECT.h>
- #include <OBJSTRM.h>
-
-
- // -[Keep_h_Extras]-
- #include <windows.h>
- #include <iostream.h>
-
- // -[Class_Dec]-
- class Shape;
- typedef Shape * PShape;
- typedef Shape & RShape;
- typedef Shape * & RPShape;
- typedef const Shape * PCShape;
- typedef const Shape & RCShape;
-
-
- class Shape : public Object, public TStreamable
- // = TITLE
- // Shape
- // = CLASSTYPE
- // Abstract
- // = AUDIENCE
- //
- // = DESCRIPTION
- // Base class for all shapes. The pure virtual function Show is redefined
- // in derived classes for their individual needs.
- //
- // Future enhancements - double click on an object to change its colour,
- // drag the corners to size the object.
- //
- // = NOTES
- //
- // = SEE ALSO
- // Object, TStreamable
- {
- // -[Keep_Class_Extras]-
-
-
- // -[Member_Data_Decs]-
- public:
- protected:
-
- // The colour in which the shape is to be painted.
- COLORREF Colour;
-
- // Height of the shape.
- int Height;
-
- // Remembers the initial value of X so that the shape can return
- // home when GoHome is called.
- int HomeX;
-
- // Remembers the initial value of Y so that the shape can return
- // home when GoHome is called.
- int HomeY;
-
- // Width of the shape.
- int Width;
-
- // X coordinate of the position of the shape.
- int X;
-
- // Y coordinate of the shape's position.
- int Y;
- private:
- public:
-
-
- // -[Member_Function_Decs]-
- public:
-
- // Constructs an object and sets its X, Y, HomeX and HomeY values.
- // Colour is initialised to blue (0x00FF0000)
- Shape(int XCoordinate, int YCoordinate);
-
- // Moves a shape back home.
- virtual void GoHome(HWND HWindow);
-
- // Returns TRUE if shape is currently at home coordinates.
- virtual BOOL isHome() const;
-
- // Returns TRUE if the point falls within the shape's bounding rectangle.
- virtual BOOL isIn(POINT Pnt);
-
- // Erases the object at the current position and Shows it at the
- // new position.
- virtual void MoveTo(HWND HWindow, int NewX, int NewY);
-
- // Sets the new colour of the shape. It returns the previous colour.
- // By default the Colour is Black (0x00000000)
- virtual COLORREF SetColour(COLORREF);
-
- // Shows a shape in the given display context at the location which
- // is specified by the value of the X,Y members.
- virtual void Show(HDC hDC) = 0;
- protected:
- private:
-
-
- // -[Persistent_1]-
- // OWL1.0 Streamability
- public:
- Shape(StreamableInit); // Used to create a new object protected:
- // Reads data in from the stream
- virtual Pvoid read(Ripstream is); // Writes data out to the stream
- virtual void write(Ropstream os);
- };
-
- // -[Persistent_2]-
- // OWL1.0 Streamability
- inline Ripstream operator >> ( Ripstream is, RShape cl )
- { return is >> (RTStreamable)cl; }
- inline Ripstream operator >> ( Ripstream is, RPShape cl )
- { return is >> (RPvoid)cl; }
- inline Ropstream operator << ( Ropstream os, RCShape cl )
- { return os << (RTStreamable)cl; }
- inline Ropstream operator << ( Ropstream os, PCShape cl )
- { return os << (PTStreamable)cl; }
-
-
- // -[Keep]-
-
-
- // -[Global_Data_Decs]-
-
-
- // -[Global_Function_Decs]-
-
- // -[Function_Defs]-
-
- // -[End_Cond]-
- #endif
-